{% extends "pretixcontrol/items/base.html" %}
{% load i18n %}
{% load rich_text %}
{% block title %}{% trans "Questions" %}{% endblock %}
{% block inside %}
    <nav id="event-nav" class="header-nav">
        <div class="navigation">
            <div class="navigation-title">
                <h1>{% trans "Questions" %}</h1>
            </div>
            {% include "pretixcontrol/event/component_link.html" %}
        </div>
    </nav>
    <p>
        {% blocktrans trimmed %}
            Questions allow your attendees to fill in additional data about their ticket. If you provide food, one
            example might be to ask your users about dietary requirements.
        {% endblocktrans %}
    </p>
    {% csrf_token %}
    <p>
        <a href="{% url "control:event.products.questions.add" organizer=request.event.organizer.slug event=request.event.slug %}" class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a new question" %}
        </a>
        <a href="{% url "control:event.products.descriptions.add" organizer=request.event.organizer.slug event=request.event.slug %}" class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a text field" %}
        </a>
    </p>
    <div class="table-responsive">
        <table class="table table-hover table-quotas">
            <thead>
            <tr>
                <th>{% trans "Question" %}</th>
                <th>{% trans "Type" %}</th>
                <th class="iconcol"></th>
                <th class="iconcol"></th>
                <th class="iconcol"></th>
                <th>{% trans "Products" %}</th>
                <th class="action-col-2"></th>
                <th class="action-col-2"></th>
            </tr>
            </thead>
            <tbody data-dnd-url="{% url "control:event.products.questions.reorder" organizer=request.event.organizer.slug event=request.event.slug %}">
            {% for q in questions %}
                <tr data-dnd-id="{{ q.id }}">
                    <td>
                        <strong>
                            {% if q.pk %}
                                {% if q.type == "DES" %}
                                    <a href="{% url "control:event.products.descriptions.edit" organizer=request.event.organizer.slug event=request.event.slug question=q.id %}">
                                {% else %}
                                    <a href="{% url "control:event.products.questions.show" organizer=request.event.organizer.slug event=request.event.slug question=q.id %}">
                                {% endif %}
                            {% endif %}
                            {{ q.question|rich_text_snippet }}
                            {% if q.pk %}
                                </a>
                            {% endif %}
                        </strong><br>
                        <small class="text-muted">{{ q.identifier }}</small>
                    </td>
                    <td>
                        {% if q.pk %}
                            {{ q.get_type_display }}
                        {% else %}
                            {% trans "System question" %}
                        {% endif %}
                    </td>
                    <td>
                        {% if q.required %}
                            <span class="fa fa-exclamation-circle text-muted" data-toggle="tooltip" title="{% trans "Required question" %}"></span>
                        {% endif %}
                    </td>
                    <td>
                        {% if q.pk and q.ask_during_checkin %}
                            <span class="fa fa-check-square text-muted" data-toggle="tooltip" title="{% trans "Ask during check-in" %}"></span>
                        {% endif %}

                    </td>
                    <td>
                        {% if q.pk and q.hidden %}
                            <span class="fa fa-eye-slash text-muted" data-toggle="tooltip" title="{% trans "Hidden question" %}"></span>
                        {% endif %}
                    </td>
                    <td>
                        {% if q.pk %}
                            <ul>
                                {% for product in q.products.all %}
                                    <li>
                                        <a href="{% url "control:event.product" organizer=request.event.organizer.slug event=request.event.slug product=product.id %}">{{ product }}</a>
                                    </li>
                                {% endfor %}
                            </ul>
                        {% else %}
                            <small>{% trans "All admission products" %}</small>
                        {% endif %}
                    </td>
                    <td class="dnd-container">
                    </td>
                    <td class="text-right flip">
                        {% if q.pk %}
                            {% if q.type == "DES" %}
                            
                                <a href="{% url "control:event.products.descriptions.edit" organizer=request.event.organizer.slug event=request.event.slug question=q.id %}" class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
                                <a href="{% url "control:event.products.descriptions.delete" organizer=request.event.organizer.slug event=request.event.slug question=q.id %}" class="btn btn-delete btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                            {% else %}
                                <a href="{% url "control:event.products.questions.show" organizer=request.event.organizer.slug event=request.event.slug question=q.id %}" class="btn btn-default btn-sm"><i class="fa fa-bar-chart"></i></a>
                                <a href="{% url "control:event.products.questions.edit" organizer=request.event.organizer.slug event=request.event.slug question=q.id %}" class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
                                <a href="{% url "control:event.products.questions.delete" organizer=request.event.organizer.slug event=request.event.slug question=q.id %}" class="btn btn-delete btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                            {% endif %}
                        {% else %}
                            <a href="{% url "control:event.settings" organizer=request.event.organizer.slug event=request.event.slug %}#tab-0-2-open"
                                    class="btn btn-default btn-sm"><i class="fa fa-wrench"></i></a>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
